POV-Ray : Newsgroups : povray.advanced-users : My first grass. : Re: My first grass. Server Time
29 Jul 2024 06:20:29 EDT (-0400)
  Re: My first grass.  
From: Corey Woodworth
Date: 4 Oct 2002 10:58:45
Message: <3d9daca5$1@news.povray.org>
> Well, your first problem is that you are testing for equality in your
> loop conditions...almost always a Bad Thing. Scalar variables in POV-Ray
> are double-precision floating point numbers, and numeric errors could
> cause them to go right past 0 without ever being exactly equal to it.
> Normally, you loop while the counter variable is higher or lower to a
> value instead of while it is not equal to a certain value.

That was code copied strait from the docs =) I didn't, and still don't
completely understand how and what trace returns. What I'm aiming for is
something that detects if the given point on the HF is somewhat flat and if
so put a sphere there.

> You are also looping down, this is just odd, since usually people loop
> up unless they have a good reason, but it works, there isn't any reason
> not to.

It just seemed more intuitive to me at the time. =)

> Finally, and probably the real reason you have a problem, the trace()
> function takes a ray direction, not an end point. All your trace() calls
> are going off in a plane perpendicular to the y axis and passing through
> < 0, 2, 0>. Use "trace(Canyon, Start, -y, Norm)" instead.

Ah! That makes sense. I thought it was an endpoint. Thats why I moved End in
relation to Start.

> Oh, and you are missing an #end...I assume this just got lost in editing
> for the post, because the code doesn't do anything without it.

Whoops =)

Ok. Here is the updated code, but it still doesn't work.

#declare Norm = <0, 0, 0>;
#declare Start = <0, 2, 0>;
#declare Counter = 1000;
#declare xCount = Counter;
#declare zCount = Counter;
#while (xCount != 0)
  #while (zCount != 0)
    #declare Start = <xCount/Counter,2,zCount/Counter>;
    #declare Inter = trace(canyon, Start, -y, Norm);
    #if (vlength(Norm)!=0)
      sphere {
        Inter, .5
        texture {
          pigment {color green 1}
        }
      }
    #end
    #declare zCount = zCount - 1;
  #end
  #declare xCount = xCount - 1;
#end


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.